const app = getApp()
const promisify = require("../../utils/promisify")

Page({
  data: {
    orders: []
  },
  onLoad: function () {
    let that = this
    promisify(wx.request)({
      url: `https://www.cumthing.world/cumthing/product/order/list` + app.ToParams({
        userId: app.globalData.userId
      }),
      method: "GET",
      header: {
        'Authorization': app.globalData.token
      }
    }).then(
      data => {
        console.log(data.data)
        let orders = data.data.data.list
        that.setData({
          orders: orders
        })
      }
    )
  },
  onShow: function () {
    let that = this
  },
  comment: function (e) {
    let orderId = JSON.stringify(e.target.dataset.item.orderId)
    promisify(wx.navigateTo)({
      url: "../comment/comment?orderId=" + orderId
    }).then(
      data => {

      },
      err => {
        console.log(err)
      }
    )

  }
})